package com.pe1n.yangtaopai.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.jude.rollviewpager.OnItemClickListener;
import com.jude.rollviewpager.RollPagerView;
import com.pe1n.yangtaopai.R;
import com.pe1n.yangtaopai.bean.ListfourBean;
import com.pe1n.yangtaopai.page.detail.view.activity.DetailActivity;
import com.pe1n.yangtaopai.view.activity.ItemOneListActivity;

import java.util.List;

/**
 * Created by Administrator on 2016/11/24.
 */

public class MyAmuontItemFourAdapter extends RecyclerView.Adapter<MyAmuontItemFourAdapter.MyViewHolder4> {
    private Context mContext;
    private List<ListfourBean.DataBean> listfourbean;

    public MyAmuontItemFourAdapter(Context mContext, List<ListfourBean.DataBean> listfourbean) {
        this.mContext = mContext;
        this.listfourbean = listfourbean;
    }


    @Override
    public MyViewHolder4 onCreateViewHolder(ViewGroup parent, int viewType) {
        View view4 = LayoutInflater.from(mContext).inflate(R.layout.item_listfour_image_layout,parent,false);
        return new MyViewHolder4(view4);
    }

    @Override
    public void onBindViewHolder(MyViewHolder4 holder, final int position) {
        ListfourBean.DataBean bean=listfourbean.get(position);
        String urlImage=bean.getImagePath();
        Glide.with(mContext)
                .load(urlImage)
                .placeholder(R.drawable.place_holder)
                .into(holder.imageView);
        holder.textView.setText(bean.getProdName());
        holder.nexttextView.setText("¥ "+bean.getProdPrice());
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(mContext, DetailActivity.class);
                String id=listfourbean.get(position).getProdId();
                String name=listfourbean.get(position).getProdName();
                intent.putExtra("id",id);
                intent.putExtra("name",name);
                mContext.startActivity(intent);
            }
        });


    }
    @Override
    public int getItemCount() {
        return listfourbean.size();
    }



    class MyViewHolder4 extends RecyclerView.ViewHolder{
        private LinearLayout linearLayout4;
        private  ImageView imageView;
        private TextView textView;
        private TextView nexttextView;

        public MyViewHolder4(View itemView) {
            super(itemView);
            imageView= (ImageView) itemView.findViewById(R.id.item_list_four_imageview);
            textView= (TextView) itemView.findViewById(R.id.item_list_four_textview);
            nexttextView= (TextView) itemView.findViewById(R.id.item_list_four_next_textview);
            linearLayout4= (LinearLayout) itemView.findViewById(R.id.item_list_four_Lineatlayout);
            linearLayout4.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                }
            });

        }
    }
}
